
capt prog drop appendmodels
*! version 1.0.0  April 26, 2023 @ 09:56:59
program appendmodels, eclass
    // using first equation of model
    version 8
    syntax namelist
    tempname b V tmp
    foreach name of local namelist {
        qui est restore `name'
        mat `tmp' = e(b)
        local eq1: coleq `tmp'
        gettoken eq1 : eq1
        mat `tmp' = `tmp'[1,"`eq1':"]
        local cons = colnumb(`tmp',"_cons")
        if `cons'<. & `cons'>1 {
            mat `tmp' = `tmp'[1,1..`cons'-1]
        }
        mat `b' = nullmat(`b') , `tmp'
        mat `tmp' = e(V)
        mat `tmp' = `tmp'["`eq1':","`eq1':"]
        if `cons'<. & `cons'>1 {
            mat `tmp' = `tmp'[1..`cons'-1,1..`cons'-1]
        }
        capt confirm matrix `V'
        if _rc {
            mat `V' = `tmp'
        }
        else {
            mat `V' = ///
            ( `V' , J(rowsof(`V'),colsof(`tmp'),0) ) \ ///
            ( J(rowsof(`tmp'),colsof(`V'),0) , `tmp' )
        }
    }
    local names: colfullnames `b'
    mat coln `V' = `names'
    mat rown `V' = `names'
    eret post `b' `V'
    eret local cmd "whatever"
end

************** make new exhibits for the vol measures ***********
use "$dataPath/SLR Projections/SLRProjectionsseries_final_8_16.dta", clear

merge m:1 year using "$dataPath/SLR Projections/scholar_study_ratio.dta"

keep if year <=2017
rename average_* *

foreach x of varlist mean sd sd_high sd_low sd_mid mean2 mean_r2  mean_mid2 mean_high2 sd2 sd_high2 sd_mid2 sd_low2 year_high mean_low2 year_high_r mean_high_r2 mean_mid_r2 mean_low_r2 sd_high_r2 sd_mid_r2 sd_low_r2 sd_r2 {
	replace `x' =`x'*3.28084
	}
replace mean_low2 = . if year < 2011

label var mean2 "Mean Projection (All Risk, 2yr)"
label var sd2 "St. Dev. of Forecasts (All Risk, 2yr)"
label var year_high "Worst Forecast (2 yr)"
/*label var mean2 "Mean"
label var sd2 "St. Dev."
label var year_high "Worst"*/


twoway (connected  year_high mean_high2 mean_mid2 mean_low2 mean2 year if year >=2007, ytitle("Feet")  color(black dred%50 dblue%50 "230 159 0*.5" black)  lpattern(solid dash shortdash longdash longdash_dot) msymbol(X d t O o))   (scatter  year_high  mean_high2 mean_mid2 mean_low2 mean2 year if year ==2001, mcolor(black dred%50 dblue%50 "230 159 0*.5" black ) msymbol(X d t O o)), xlabel(2001(3)2017) xtitle("") graphregion(color(white)) ylabel(1(1)5.5) legend(off) name(g1, replace) text(3 2001 "2001 IPCC Report", placement(east))  text(5 2013 "Worst Projection" "(Across Scenarios)", color(black))  text(3.8 2015 "Mean Projection" "(High Emissions)", color(dred)) text(1.1 2005 "Mean Projection"  "(Reduced Emissions)", color(dblue)) text(1.1 2013 "Mean Projection" "(Low Emissions)", color("230 159 0")) text(2 2005 "Mean Projection"  "(Across Scenarios)", color(lack)) 
*text(2.4 2007 "2007 IPCC Report", placement(west))
graph export "$graphPath/worst_mean_paulalternate.png", replace
graph export "$graphPath/worst_mean_paulalternate.pdf", replace


twoway (connected  year_high_r mean_high_r2 mean_mid_r2 mean_low_r2 mean_r2 year if year >=2007, ytitle("Feet")  color(black dred%50 dblue%50 "230 159 0*.5" black)  lpattern(solid dash shortdash longdash longdash_dot) msymbol(X d t O o))   (scatter  year_high_r mean_high_r2 mean_mid_r2 mean_low_r2 mean_r2 year if year ==2001, mcolor(black dred%50 dblue%50 "230 159 0*.5" black ) msymbol(X d t O o)), xlabel(2001(3)2017) xtitle("") graphregion(color(white)) ylabel(1(1)7) legend(off) name(g1, replace) text(3 2001 "2001 IPCC Report", placement(east))  text(6 2014 "Worst Projection" "(Across Scenarios)", color(black))  text(3.8 2014 "Mean Projection" "(High Emissions)", color(dred)) text(2.1 2010.5 "Mean Projection"  "(Reduced Emissions)", color(dblue)) text(1.1 2013 "Mean Projection" "(Low Emissions)", color("230 159 0")) text(1.1 2005 "Mean Projection"  "(Across Scenarios)", color(black)) 
*text(2.4 2007 "2007 IPCC Report", placement(west))
graph export "$graphPath/worst_mean_paulalternate_appendix.png", replace
graph export "$graphPath/worst_mean_paulalternate_appendix.pdf", replace

twoway (connected   sd_high2 sd_mid2 sd_low2 sd2 year if year >=2007, ytitle("Feet")  color(dred%50 dblue%50 "230 159 0*.5" black)  lpattern( dash shortdash longdash longdash_dot) msymbol(o d t O X))   (scatter   sd_high2 sd_mid2 sd_low2 sd2 year if year ==2001, mcolor( dred%50 dblue%50 "230 159 0*.5" black)   msymbol(o d t O X)), xlabel(2001(3)2017) xtitle("") graphregion(color(white)) ylabel(0.1(0.2)1) legend(off) name(g1, replace) text(0.5 2001 "2001 IPCC Report", placement(east))  text(.9 2011 "Standard Dev. of Projection" "(High Emissions)", color(dred)) text(.175 2007 "Standard Dev. of Projection"  "(Reduced Emissions)", color(dblue)) text(.2 2014.2 "Standard Dev. of Projection" "(Low Emissions)", color("230 159 0"))  text(.25 2004 "Standard Dev. of Projection"  "(Across Scenarios)", color(black)) 

*text(0.24 2007 "2007 IPCC Report", placement(west))
graph export "$graphPath/sd_paulalternate.png", replace
graph export "$graphPath/sd_paulalternate.pdf", replace

twoway (connected   sd_high_r2 sd_mid_r2 sd_low_r2 sd_r2 year if year >=2007, ytitle("Feet")  color(dred%50 dblue%50 "230 159 0*.5" black)  lpattern( dash shortdash longdash longdash_dot) msymbol(o d t O X))   (scatter   sd_high2 sd_mid2 sd_low2 sd2 year if year ==2001, mcolor( dred%50 dblue%50 "230 159 0*.5" black)   msymbol(o d t O X)), xlabel(2001(3)2017) xtitle("") graphregion(color(white)) ylabel(0.1(0.2)1) legend(off) name(g1, replace) text(0.5 2001 "2001 IPCC Report", placement(east))  text(.85 2011 "Standard Dev. of Projection" "(High Emissions)", color(dred)) text(.165 2007 "Standard Dev. of Projection"  "(Reduced Emissions)", color(dblue)) text(.2 2014.2 "Standard Dev. of Projection" "(Low Emissions)", color("230 159 0"))  text(.25 2004 "Standard Dev. of Projection"  "(Across Scenarios)", color(black)) 

*text(0.24 2007 "2007 IPCC Report", placement(west))
graph export "$graphPath/sd_paulalternate_appendix.png", replace
graph export "$graphPath/sd_paulalternate_appendix.pdf", replace


twoway (bar total  year, color(%20)  ytitle("Total")  lpattern(solid dash))  (line ratio year,  yaxis(2) ytitle("Ratio", axis(2))), title("Scholar Ratio") ylabel(0(4000)12000) xtitle("")graphregion(color(white)) legend(off) name(g4,replace)
twoway (connected ratio year, ytitle("Ratio of articles with mention of High  vs. Reduced Emissions ")),  xtitle("") graphregion(color(white)) legend(off) name(g4,replace) xlabel(2001(3)2017)
graph export "$graphPath/ratio_paulalternate2.png", replace
graph export "$graphPath/ratio_paulalternate2.pdf", replace

twoway (connected total year, ytitle("Total articles with mention of High or Reduced Emissions")),  xtitle("") graphregion(color(white)) legend(off) name(g4,replace) xlabel(2001(3)2017) ylabel(0(4000)12000)
graph export "$graphPath/total_paulalternate2.png", replace
graph export "$graphPath/total_paulalternate2.pdf", replace
